import { translateByCode } from '@/lib/getTransData.js';
import validator from '../index.js';
// 账号注册验证
export class RegisterDto_Rules {
  constructor() {
    this.phoneNumber = [
      validator.required(translateByCode('rules.requiredUserName')),
      {
        validator (rule, value, callback) {
          callback(validator.checkPhone(value, translateByCode('rules.validTelephone')));
        },
        trigger: 'blur'
      }
    ];
    this.password = [
      validator.required(translateByCode('rules.requiredPassword')),
      {
        validator (rule, value, callback) {
          callback(validator.checkPwd(value, translateByCode('rules.validPassword')));
        },
        trigger: 'blur'
      }
    ];
    this.code = [
      {
        required: true,
        message: translateByCode('rules.verifyCode'),
        trigger: 'blur'
      },
      {
        min: 6,
        max: 6,
        message: translateByCode('rules.validVerifyCode'),
        trigger: 'blur'
      }
    ];
  }
}
export class CreateRegisterInput_Rules {
  constructor() {
    this.idCard.name = [{ required: true, message: '姓名不能为空', trigger: 'blur' }];
    this.idCard.idCardNumber = [
      {
        required: true, message: '身份证号码不能为空', trigger: 'blur'
      }, {
        validator (rule, value, callback) {
          callback(validator.checkIdNumber(value, '身份证号码格式不正确'));
        },
        trigger: 'blur'
      }
    ];
    this.idCard.idCardFrontImage = [
      { required: true, message: '身份证正面不能为空', trigger: 'change' }
    ];
    this.idCard.idCardBackImage = [
      { required: true, message: '身份证反面不能为空', trigger: 'change' }
    ];
  }
}

// 账号注册验证
export class WxRegisterDto_Rules {
  constructor() {
    this.phoneNumber = [
      validator.required(translateByCode('rules.userName')),
      {
        validator (rule, value, callback) {
          callback(validator.checkPhone(value, translateByCode('rules.validTelephone')));
        },
        trigger: 'blur'
      }
    ];
    this.password = [
      validator.required(translateByCode('rules.requiredPassword')),
      {
        validator (rule, value, callback) {
          callback(validator.checkPwd(value, translateByCode('rules.validPassword')));
        },
        trigger: 'blur'
      }
    ];
    this.code = [
      {
        required: true,
        message: translateByCode('rules.verifyCode'),
        trigger: 'blur'
      },
      {
        min: 6,
        max: 6,
        message: translateByCode('rules.validVerifyCode'),
        trigger: 'blur'
      }
    ];
  }
}
